<?php

	if(!defined('YMT')) exit;
	
	/**
	 * @package Yomm
	 * @author bsuter
	 *
	 */
	Class Yomm_Registry {
		
		private static $_registry = array();
		
		/**
		 * @param $key [string] name/key of the variable
		 * @param $value [mixed] value of the variable
		 */
		public static function set($key, $value, $overwrite = false)
		{
			if(self::has($key) && $overwrite === false)
			{
				throw new Yomm_Error("Unable to set token {$key}. It is already existing and overwrite is disabled!");
			}
			
			self::$_registry[$key] = $value;
		}
		
		public static function has($key)
		{
			if(isset(self::$_registry[$key]))
			{
				return true;
			}
			
			return false;
		}
		
		public static function get($key)
		{
			if(!self::has($key))
			{
				throw new Yomm_Error("Unable to get token {$key}. The variable is not existing!");
			}
			
			return self::$_registry[$key];
		}
		
	}